-
-
Notifications
You must be signed in to change notification settings - Fork 747
Bugfix: Properly stop network traffic recording #5127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: Properly stop network traffic recording #5127
Conversation
Hmm, the tests are failing on Puppeteer. I’ll take a look tomorrow to try to understand why. Do you have any idea why the second amOnPage doesn’t pass? I’m not very familiar with Puppeteer. |
For Puppeteer, I think I may have identified the issue, but I’d like confirmation since I’m not an expert in Puppeteer or the Codecept recorder. In this helper we set CodeceptJS/lib/helper/Puppeteer.js Lines 2602 to 2610 in 15a288e
However, when we stop, we never set this value back to CodeceptJS/lib/helper/Puppeteer.js Lines 2594 to 2596 in 15a288e
My proposal is to modify it like this: async stopRecordingTraffic() {
await this.page.setRequestInterception(false);
stopRecordingTraffic.call(this);
} From what I’ve read, if The tests passed with this modification, but I have one last question: what would be the impact of making |
thanks for pointing it out @Samuel-StO, maybe it's a missing piece when trying to consolidate the actions to be shared among Puppeteer, Playwright and WebDriver helpers -> https://github.com/codeceptjs/CodeceptJS/pull/4263/files#diff-8b5994d9478083cafc2a9a5943b10cbff2648e67b092689c43e5f3d8924b4096R107 |
…ion handling for pupperteer
Context
In the Playwright helper,
startRecordingTraffic()
attaches a listener on therequestfinished
event to capture completed network requests.However,
stopRecordingTraffic()
was callingremoveAllListeners('request')
, which does not removerequestfinished
listeners. This traffic is still recording event after the stopRecordingTraffic.Also, in
seeTraffic
, the condition was too strict: it required bothrecording === true
andrecordedAtLeastOnce
. This prevented assertions on traffic afterstopRecordingTraffic()
.Fix
stopRecordingTraffic()
to remove listeners for bothrequest
andrequestfinished
.startRecordingTraffic()
, I chose to keeprequestfinished
and just ensure proper cleanup. This minimizes changes and avoids breaking compatibility.seeTraffic
condition: now it only checksrecordedAtLeastOnce
. Users can assert collected traffic even after recording is stopped.Tests
stopRecordingTraffic()
, new requests are no longer collected.Impact
actions.js
generic and safe.seeTraffic
usable after stopping traffic recording.Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs
)npm run lint
)npm test
)